package com.sop.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.sop.model.RoleInfo;
import com.sop.model.vo.RoleInfoVo;
import com.sop.service.RoleService;
import common.base.GridPage;

@Controller
@RequestMapping("/role")
public class RoleController {

	@Autowired
	private RoleService roleService;
	
	@ResponseBody
	@RequestMapping("/findRoles")
	public List<RoleInfo>  findPeoples(Model model){
		List<RoleInfo> roleList = roleService.findAll();
		return roleList;
	}
	
	/**
	 * 高级搜索
	 * @param roleInfoVo
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/findByPages")
	public GridPage<RoleInfo>  findByPages(RoleInfoVo  roleInfoVo){
		return  roleService.findPagerBySearchVo(roleInfoVo);
	}
	
	@ResponseBody
	@RequestMapping("/getRole")
	public RoleInfo  getPeople(Integer id){
		return roleService.get(id);
	}
	
	@ResponseBody
	@RequestMapping("/add")
	public RoleInfo  add(RoleInfo info){
		RoleInfo role = roleService.add(info);
		return role;
	}
	
	@ResponseBody
	@RequestMapping("/update")
	public RoleInfo  update(RoleInfo info){
		RoleInfo role = roleService.update(info);
		return role;
	}
	
	@ResponseBody
	@RequestMapping("/delete")
	public boolean  delete(Integer id){
		roleService.delete(id);
		return true;
	}
}
